package com.ruoyi.customerSample.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.customerSample.domain.CustomerFeedback;
import com.ruoyi.customerSample.service.ICustomerFeedbackService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 原因解决反馈Controller
 * 
 * @author lgq
 * @date 2023-10-13
 */
@Api(value="原因解决反馈管理",tags = "原因解决反馈接口")
@RestController
@RequestMapping("/custSam/feedback")
public class CustomerFeedbackController extends BaseController
{
    @Autowired
    private ICustomerFeedbackService customerFeedbackService;

    /**
     * 查询原因解决反馈列表
     */
    @GetMapping("/list")
    @ApiOperation(value="查询原因解决反馈列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "页数", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "每页记录数", required = true, dataType = "String"),
    })
    public TableDataInfo list(CustomerFeedback customerFeedback)
    {
        startPage();
        List<CustomerFeedback> list = customerFeedbackService.selectCustomerFeedbackList(customerFeedback);
        return getDataTable(list);
    }

    /**
     * 导出原因解决反馈列表
     */
    @Log(title = "原因解决反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomerFeedback customerFeedback)
    {
        List<CustomerFeedback> list = customerFeedbackService.selectCustomerFeedbackList(customerFeedback);
        ExcelUtil<CustomerFeedback> util = new ExcelUtil<CustomerFeedback>(CustomerFeedback.class);
        util.exportExcel(response, list, "原因解决反馈数据");
    }

    /**
     * 获取原因解决反馈详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value="获取原因解决反馈详细信息")
    @ApiImplicitParam(paramType="query", name = "id", value = "主键", required = true, dataType = "String")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(customerFeedbackService.selectCustomerFeedbackById(id));
    }

    /**
     * 新增原因解决反馈
     */
    @Log(title = "原因解决反馈", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="新增原因解决反馈")
    public AjaxResult add(@ApiParam(name="原因解决反馈",value="传入json格式",required=true)@RequestBody CustomerFeedback customerFeedback)
    {
        return toAjax(customerFeedbackService.insertCustomerFeedback(customerFeedback));
    }

    /**
     * 修改原因解决反馈
     */
    @Log(title = "原因解决反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="修改原因解决反馈")
    public AjaxResult edit(@ApiParam(name="原因解决反馈",value="传入json格式",required=true)@RequestBody CustomerFeedback customerFeedback)
    {
        return toAjax(customerFeedbackService.updateCustomerFeedback(customerFeedback));
    }

    /**
     * 删除原因解决反馈
     */
    @Log(title = "原因解决反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value="删除原因解决反馈")
    @ApiImplicitParam(paramType="query", name = "id", value = "主键", required = true, dataType = "String")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(customerFeedbackService.deleteCustomerFeedbackByIds(ids));
    }
}
